﻿using System;
using System.Data;
using System.Collections.Generic;
using BOMS.Model;
namespace BOMS.BLL
{
    /// <summary>
    /// 业务逻辑类S_BatSubLog 的摘要说明。
    /// </summary>
    public class S_BatSubLog
    {
        private readonly BOMS.DAL.S_BatSubLog dal = new BOMS.DAL.S_BatSubLog();
        public S_BatSubLog()
        { }
        #region  成员方法
       
        /// <summary>
        /// 得到一个最接近的对象实体（-1电池组的，否则是电池的 ）
        /// </summary>
        /// <param name="dtm"></param>
        /// <param name="Generation"></param>
        /// <param name="EquipID"></param>
        /// <param name="BatteryGrp"></param>
        /// <param name="BatteryID"></param>
        /// <returns></returns>
        public object GetNearlyModel(DateTime dtm, byte Generation, string EquipID, string BatteryGrp, int BatteryID)
        {
            return dal.GetNearlyModel(dtm, Generation, EquipID, BatteryGrp, BatteryID);
        }
        public List<BOMS.Model.S_BatSubLog> GetRealTimeBatteryData(int Generation, string EquipID, string BatteryGroup)
        {
            DataTable dt = dal.GetRealTimeBatteryData(Generation, EquipID, BatteryGroup);
            List<BOMS.Model.S_BatSubLog> list = DataTableToList(dt);
            return list;
        }
       
      
        
        /// <summary>
        /// 分页，获得数据列表
        /// </summary>
        public List<BOMS.Model.S_BatSubLog> GetModelListFromPage(string strWhere,string strOrderby, int pageSize, int curPage, out int recordCount)
        {
            DataSet ds = dal.GetListFromPage(strWhere,strOrderby,pageSize,curPage,out recordCount);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<BOMS.Model.S_BatSubLog> DataTableToList(DataTable dt)
        {
            List<BOMS.Model.S_BatSubLog> modelList = new List<BOMS.Model.S_BatSubLog>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                BOMS.Model.S_BatSubLog model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new BOMS.Model.S_BatSubLog();                   
                    dal.AssignModel(dt.Rows[n], model);
                    modelList.Add(model);
                }
            }
            return modelList;
        }

       

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}

